(1) Field of the Invention
The present invention relates to an image coding device which codes data regarding moving pictures, and more particularly to a coding device according to the H.264/AVC standard.
(2) Description of the Related Art
With the development of digital technologies, technologies for coding imaged have progressed and developed. However, image data (especially moving picture data) has a large amount of data. Therefore, when digital image data is coded and then broadcasted or transferred via a medium such as a DVD, the amount of the data becomes quite large. Particularly, high-definition (HD) broadcasting has recently been utilized, but a data amount of HD image is six times larger compared to a conventional standard-definition (SD) image.
With the development of digital imaging technologies, data compression technologies have been utilized and developed for digital image data, in order to address the data amount increase. One example of the development is compression technologies, and especially a technology for compressing image data taking advantage of characteristics of the image data. Moreover, because of recent improvements in data processing ability of computers and other apparatuses, complicated arithmetic operations in the compression technologies have been realized, so that compression rates of image data have been significantly increased. For example, an MPEG-2 standard is a compression technology employed in satellite and terrestrial digital HD broadcasting. In satellite digital HD broadcasting, image data can be compressed to about 1:30 using the MPEG-2 method.
A further developed image compression technology is an AVC/H.264 standard. The AVC/H.264 standard can realize a compression rate that is twice higher compared to the MPEG-2 standard. The AVC/H.264 employs and combines various compression technologies to realize such a high compression rate. As a result, the amount of arithmetic operation is also increased significantly.
One of the compression technologies employed in the AVC/H.264 standard is entropy coding (variable length coding). As the entropy coding, there are two different methods called Context-based Adaptive Variable Length Coding (CAVLC) and Context-based Adaptive Binary Arithmetic Coding (CABAC). According to the CAVLC method, when a DCT coefficient is coded, a Run symbol representing a length of continuous zeros and a Level symbol are respectively coded in a direction opposite to a scanning direction, referring to respective variable length coding tables.
On the other hand, the CABAC is a method of coding a code according to an occurrence possibility of the code. The occurrence possibility is varied depending on time, thereby adaptively changing setting of the possibility of occurrence. Such a method is generally called an arithmetic coding. In the CABAC, in addition to such common arithmetic coding, another technique is used to assign each code with each context and change the occurrence possibility for each context.
The CABAC includes two main processes. The first process is called binarization, by which to-be-coded multi-valued data (a syntax) is converted to binary data. The second process is calculating a context of the converted binary data, and then applying arithmetic coding to the binary data according to the calculated context.
In the arithmetic coding, an occurrence possibility is calculated for each bit in the binary data to be used in the coding, and at the same time the occurrence possibility is updated. Since the process is performed for each bit, the operation speed is normally one bit per one clock. Further, since the occurrence possibility is adaptively changed for each bit and updated depending on a value of the bit, it is difficult to know an exact amount of output coded data, prior to the coding.
Furthermore, in the AVC/H.264 standard, a maximum coding amount of one macroblock is restricted to 3200 bits, in a case where a 4-2-0 format and 8 bit_depth. When a macroblock is coded and a resulting coding amount becomes greater than 3200 bits, it is necessary to modify conditions for coding the macroblock and code the macroblock again under the modified conditions. Therefore, there is another method of treating mb_type as I_PCM, and storing, as a bitstream, the I_PCM data instead of coded data. Here, it is also difficult to exactly know a resulting output coding amount by the CABAC until the data is actually coded and the coded data is outputted. Therefore, a decision is made, after the CABAC, as to whether or not the coding satisfies the restriction of the maximum coding amount of a macroblock.
On the other hand, still another method is disclosed in Japanese Patent Application Laid-Open No. 2004-135251 publication, for example. By the method, an amount of data inputted to an arithmetic coding circuit is monitored. Then, if an amount of the input data per certain portion exceeds a predetermined amount, the input data is not coded, but data coded by a different parameter or non-compressed data is treated as input data.
FIG. 1 is a block diagram showing a functional structure of the conventional image coding device.
The image coding device 50 shown in FIG. 1 is one example of a conventional image coding device which codes inputted image data and outputs the coded data as a bitstream. The following describes processing performed by the image coding device 50.
Note that, the image data is data regarding a moving picture which includes: substantive data, such as data of a macroblock included in the moving picture; a control information, such as a macroblock type (mb_type); other attribute information; and the like.
When data regarding a moving picture, which is to be coded, is received, the data is passed to a motion prediction unit 51, an intra-picture prediction unit 52, and an I_PCM data buffer 53. The motion prediction unit 51 detects a block similar to a to-be-coded block from another picture, then obtains a differential image between the to-be-coded block and the detected block, and outputs the differential image and a motion vector. The intra-picture prediction unit 52 predicts image of the to-be-coded block in the picture using image of adjacent blocks, then obtains a differential image between the to-be-coded block and the prediction block, and outputs the differential image and information indicating the prediction method. Further, the I_PCM data buffer 53 is a buffer, in which I_PCM data is stored. The I_PCM data is original data of an input moving picture image.
The input selection unit 54 selects output from the motion prediction unit 51 or output from the intra-picture prediction unit 52, and passes the selected data to an orthogonal transformation unit 55. The orthogonal transformation unit 55 performs Discrete Consine Transform (DCT) which is a kind of orthogonal transformation. The orthogonal transformation unit 55 applies DCT to the obtained data and provides the resulting DCT coefficient to a quantization unit 56 which quantizes the DCT coefficient. The quantized DCT coefficient is passed to a binarizer 57. In the binarizer 57, the quantized DCT coefficient is converted to binary data and then coded by a CABAC encoder 59. The coded data is passed to an output selection unit 61 via an output buffer 61.
Here, an I_PCM decision unit 58 monitors a data amount of output from the binarizer 57 in the above-described processing, and can decide, according to an amount of binarized data, whether the data to be outputted as a bitstream is to be data coded by the CABAC encoder 59, or I_PCM data stored in the I_PCM data buffer 53. Alternatively, the I_PCM decision unit 58 monitors a data amount of output from the CABAC encoder 59, and can decide whether data to be outputted as a bitstream is to be I_PCM data or coded data, according to whether or not the code amount, which is an actual amount of coded data, is over 3200 bits. The output selection unit 61 outputs coded data or I_PCM data according to the decision of the I_PCM decision unit 58.
Here, according to the AVC/H.264, data of a macroblock prior to a target macroblock is used for intra-picture prediction, motion prediction, and the like. Thus, like the above-described conventional technologies, when the decision of whether or not a maximum coding amount restriction on a macroblock is satisfied is performed after CABAC, intra-picture prediction and motion prediction of the next macroblock can not be started until completion of the CABAC of the macroblock.